using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Diagnostics;
using FiltronASP.Logger;


namespace FiltronASP.Helpers.ErrorHandling
{
    /// <summary>
    /// Klasa odpowiedzialna za obsluge bledow za pomoca <code>Elmaha</code>.
    /// </summary>
    public class HandleErrorWithMyLoggerAttribute : HandleErrorAttribute
    {
        /// <summary>
        /// Metoda wywolywana w momencie wystapienia wyjatku.
        /// </summary>
        /// <param name="filterContext">kontekst wyjatku</param>
        public override void OnException(ExceptionContext filterContext)
        {
            base.OnException(filterContext);
            if (filterContext != null)
            {
                LogException(filterContext.Exception);
            }   //if
        }

        /// <summary>
        /// Logowanie wyjatkow.
        /// </summary>
        /// <param name="exception">wyjatek do zalogowania</param>
        private static void LogException(Exception exception)
        {
            MyLogger.Log(exception);
        }

    }
}
